package com.back.controller;

import com.back.model.dto.DoAnswerDTO;
import com.back.model.dto.SubmitQuestionDTO;
import com.back.model.reslut.Result;
import com.back.model.vo.QuestionsVo;
import com.back.service.QuestionsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("/question")
public class QuestionController {

    @Resource
    private QuestionsService questionsService;

    //查询题目列表（隐藏答案）
    @PostMapping("/list")
    public Result<List<QuestionsVo>> getTaskList(@RequestBody DoAnswerDTO doAnswerDTO) {
        List<QuestionsVo> voList = questionsService.getQuestionList(doAnswerDTO);
        return Result.successData(voList);
    }

    @PostMapping("/submit")
    public Result<BigDecimal> submitQuestion(@RequestBody SubmitQuestionDTO submitQuestionDTO) {
        Result<BigDecimal> res = questionsService.submitQuestion(submitQuestionDTO);
        return res;
    }

}
